//
//  songDetails.m
//  cwRadio
//
//  Created by Niels Buekers on 12/11/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "songDetails.h"

@implementation songDetails
@synthesize title,artist,album,genre,cover, url, stream,coverUrl;

//getters for coping when only the tail of the playlist is replaced
-(NSString*) getArtist{
	return artist;
}
-(NSString*) getUrl{
	return url;
}
-(NSString*) getStream{
	return stream;
}
-(NSString*) getTitle{
	return title;
}
-(NSString*) getAlbum{
	return album;
}
-(genres) getGenre{
	return genre;
}
-(NSInteger) getDuration{
	return duration;
}
-(NSInteger) getId{
	return _id;
}
-(NSString*) getCoverUrl{
	return coverUrl;
}
-(UIImage *) getCover{
	return cover;
}


//when copying to this class, a problem with occurs with memory that is removed afterwards, one solution is to copy everything in the class seperatly
-(void) setPointerType:(NSString*)a stream:(NSString*)st url:(NSString*)u album:(NSString*)al coverUrl:(NSString*)c title:(NSString*)t{
	self.artist=[[NSString alloc] initWithString:a];
	self.stream=[[NSString alloc] initWithString:st];
	self.url=[[NSString alloc] initWithString:u];
	self.album=[[NSString alloc] initWithString:al];
	self.title=[[NSString alloc] initWithString:t];
	self.coverUrl=[[NSString alloc] initWithString:c];
	coverUrl = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:coverUrl]]];
}

//the initialiser, loading the cover happens within the function itself
-(songDetails*) initWithArtist:(NSString*)at title:(NSString*)t album:(NSString*)al coverUrl:(NSString*) cu genre:(genres)g url:(NSString*)ur stream:(NSString*)stre _id:(NSInteger)i duration:(NSInteger)du{
	self = [super init];
	if(self){
		coverUrl=cu;
		artist = at;
		title = t;
		album = al;
		genre = g;
		url = ur;
		stream=stre;
		_id = i;
		duration =du;
		cover = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:coverUrl]]];
	}
	return self;
}

- (void)dealloc {
    [artist release];
    [stream release];
	[url release];
	[album release];
	[coverUrl release];
	[title release];
    [super dealloc];
}

@end
